package com.bawei.common.mvi

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.ToastUtils

/**
 * 作者：Jason
 * 日期：2023/11/16
 * 描述：基类Fragment
 */
abstract class BaseFragment<VDB : ViewDataBinding> : Fragment() {

    lateinit var mDataBinding: VDB

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        mDataBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false)
        initViews()
        initData()
        updateUI()
        return mDataBinding.root
    }

    fun showToastMessage(msg: String) {
        if (!msg.isNullOrEmpty()) {
            ToastUtils.showLong(msg)
        }
    }

    abstract fun getLayoutId(): Int
    abstract fun initViews()
    abstract fun initData()
    abstract fun updateUI()


}